from docx import Document
from docx.enum.style import WD_STYLE_TYPE, WD_BUILTIN_STYLE
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT, WD_TAB_LEADER
from docx.oxml.ns import qn
from docx.shared import Pt, Inches, RGBColor


def add_paragraph_heading1(docx,text):
    p = docx.add_paragraph(style=f'Heading 1')
    # 上行间距离
    p.paragraph_format.space_before = Pt(0)
    # 下行间距离
    p.paragraph_format.space_after = Pt(0)
    # 左缩进
    p.paragraph_format.left_indent = Pt(0)
    # 填充字符串
    run = p.add_run(text)
    # 英文新罗马
    run.font.name = 'Times New Roman'
    # 中文黑体
    run.element.rPr.rFonts.set(qn('w:eastAsia'), '黑体')
    # 字体黑色
    run.font.color.rgb = RGBColor(0,0,0)
    run.font.bold = False
    # 字体大小
    run.font.size = Pt(12)
    # 斜体
    run.font.italic = False

def add_paragraph_heading2(docx,text):
    p = docx.add_paragraph(style=f'Heading 2')
    # 上行间距离
    p.paragraph_format.space_before = Pt(0)
    # 下行间距离
    p.paragraph_format.space_after = Pt(0)
    # 左缩进
    p.paragraph_format.left_indent = Pt(10)
    # 填充字符串
    run = p.add_run(text)
    # 英文新罗马
    run.font.name = 'Times New Roman'
    # 中文黑体
    run.element.rPr.rFonts.set(qn('w:eastAsia'), '楷体')
    # 字体黑色
    run.font.color.rgb = RGBColor(0,0,0)
    run.font.bold = False
    # 字体大小
    run.font.size = Pt(12)
    # 斜体
    run.font.italic = False

def add_paragraph_heading3(docx,text):
    p = docx.add_paragraph(style=f'Heading 3')
    # 上行间距离
    p.paragraph_format.space_before = Pt(0)
    # 下行间距离
    p.paragraph_format.space_after = Pt(0)
    # 左缩进
    p.paragraph_format.left_indent = Pt(20)
    # 填充字符串
    run = p.add_run(text)
    # 英文新罗马
    run.font.name = 'Times New Roman'
    # 中文黑体
    run.element.rPr.rFonts.set(qn('w:eastAsia'), '仿宋_GB2312')
    # 字体黑色
    run.font.color.rgb = RGBColor(0,0,0)
    run.font.bold = True
    # 字体大小
    run.font.size = Pt(12)
    # 斜体
    run.font.italic = False

def add_paragraph_heading4(docx,text):
    p = docx.add_paragraph(style=f'Heading 4')
    # 上行间距离
    p.paragraph_format.space_before = Pt(0)
    # 下行间距离
    p.paragraph_format.space_after = Pt(0)
    # 左缩进
    p.paragraph_format.left_indent = Pt(30)
    # 填充字符串
    run = p.add_run(text)
    # 英文新罗马
    run.font.name = 'Times New Roman'
    # 中文黑体
    run.element.rPr.rFonts.set(qn('w:eastAsia'), '仿宋_GB2312')
    # 字体黑色
    run.font.color.rgb = RGBColor(0,0,0)
    run.font.bold = False
    # 字体大小
    run.font.size = Pt(12)
    # 斜体
    run.font.italic = False

def add_paragraph_heading5(docx,text):
    p = docx.add_paragraph(style=f'Body Text')
    # 上行间距离
    p.paragraph_format.space_before = Pt(0)
    # 下行间距离
    p.paragraph_format.space_after = Pt(0)
    # 左缩进
    p.paragraph_format.left_indent = Pt(30)
    # 填充字符串
    run = p.add_run(text)
    # 英文新罗马
    run.font.name = 'Times New Roman'
    # 中文黑体
    run.element.rPr.rFonts.set(qn('w:eastAsia'), '仿宋_GB2312')
    # 字体黑色
    run.font.color.rgb = RGBColor(0,0,0)
    run.font.bold = False
    # 字体大小
    run.font.size = Pt(12)
    # 斜体
    run.font.italic = False


